const Router = require('koa-router');
const {auth,hadAdminPermission} = require('../middleware/auth.middleware')
const {upload,create,update,deletegoods,restoregoods,findAll} = require('../controller/goods.controller')
const {validator} = require('../middleware/goods.middleware')
const router = new Router({prefix:'/goods'});

/**
 * @param auth 是否登录
 * @param hadAdminPermission 是否是管理员
 * @param validator 参数检查
 * 
 */

//商品图片上传接口
router.post('/upload',auth,hadAdminPermission,upload)

//发布商品接口
router.post('/',auth,hadAdminPermission,validator,create)

//修改商品接口
router.post('/update',auth,hadAdminPermission,validator,update)

//硬删除接口
router.post('/remove',auth,hadAdminPermission,deletegoods)

//商品下架接口
router.post('/off',auth,hadAdminPermission,deletegoods)

//商品上架接口
router.post('/on',auth,hadAdminPermission,restoregoods)

router.get('/findAll',auth,hadAdminPermission,findAll)
module.exports = router